package com.acwing.chapter3;

import java.io.*;

/**
 * @author anan
 * @create 2021-08-25 23:39
 */
public class Zuidayihuodui143 {
    private static int N = 100010;
    private static int[][] son = new int[N*31][2]; //数组的第一个元素是所有数据的总长度
    private static int idx = 0;

    public static int max(int x1, int x2){
        return x1 >= x2 ? x1 : x2;
    }
    public static int abs(int x){
        return -x;
    }

    public static int[] toBindary(int a){
        int[] intArray = new int[31];
        for (int i = 0; i <= 30 ; i++) {
            intArray[i] = a%2;
            a = a >> 1;
        }
        return intArray;
    }

    public static void insert(int a){
        int[] ints = toBindary(a);
        int p = 0;
        int u;
        for (int i = 30; i >= 0 ; i--) {
            u = ints[i];
            if (son[p][u] == 0) son[p][u] = ++idx;
            p = son[p][u];
        }
    }

    public static int query(int x){
        int[] ints = toBindary(x);
        int p = 0;
        int u;
        int ref = 0;
        for (int i = 30; i >= 0 ; i--) {
            u = abs(ints[i] - 1);
            if (son[p][u] != 0){
                ref += Math.pow(2, i);
                p = son[p][u];
            }
            else p = son[p][ints[i]];
        }
        return ref;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] str1 = reader.readLine().split(" ");
        int N = Integer.parseInt(str1[0]);
        String[] str2 = reader.readLine().split(" ");
        int x = 0;
        for (int i = 0; i < N; i++) {
            x = Integer.parseInt(str2[i]);
            insert(x);
        }

        int result = 0;
        for (int i = 0; i < N; i++) {
            x = Integer.parseInt(str2[i]);
            result = max(query(x), result);
        }

        writer.write(result + "\n");
        writer.flush();
        writer.close();
        reader.close();
    }
}
